home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ für Kids
/
C++ for kids.iso
/
Buch
/
Monster3.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-19
|
3KB
|
94 lines
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Monster3.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
const String Pfad = "c:\\cpp\\buch\\";
class TMonster
{
private:
String Name;
String Wesen;
String Bild;
public:
void Erscheinen(void);
virtual String Typ (void) {return "Monster";};
TMonster (String N, String W, String Datei);
};
class TGMonster : public TMonster
{
public:
virtual String Typ (void) {return "GeistesMonster";};
TGMonster (String N, String W, String Datei);
};
class TSMonster : public TMonster
{
public:
virtual String Typ (void) {return "SeelenMonster";};
TSMonster (String N, String W, String Datei);
};
//---------------------------------------------------------------------------
TMonster *Frank;
TGMonster *Albert;
TSMonster *Sigmund;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
TMonster::TMonster (String N, String W, String Datei)
{
Name = N; Wesen = W; Bild = Datei;
}
//---------------------------------------------------------------------------
TGMonster::TGMonster (String N, String W, String Datei)
: TMonster (N, W, Datei)
{
}
//---------------------------------------------------------------------------
TSMonster::TSMonster (String N, String W, String Datei)
: TMonster (N, W, Datei)
{
}
//---------------------------------------------------------------------------
void TMonster::Erscheinen (void)
{
Form1->Label1->Caption = "Name: " + Name;
Form1->Label2->Caption = "Wesen: " + Wesen;
Form1->Label3->Caption = "Typ: " + Typ();
Form1->Image1->Picture->LoadFromFile (Pfad+Bild);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Frank = new TMonster ("Frankie", "ungew÷hnlich", "Frank.bmp");
Albert = new TGMonster ("Berti", "nachdenklich", "Albert.bmp");
Sigmund = new TSMonster ("Sigi", "mitfⁿhlend", "Sigmund.bmp");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Frank->Erscheinen ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Albert->Erscheinen ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Sigmund->Erscheinen ();
}
//---------------------------------------------------------------------------